package org.adw.launcher2.ld.secret.ui.adapter;

import java.util.List;
import org.adw.launcher2.R;
import org.adw.launcher2.ld.secret.dom.contact.ConversationSMS;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ConversationSMSAdapter extends ArrayAdapter<ConversationSMS>{
	private Context context;
	private LayoutInflater inflater;
	public ConversationSMSAdapter(Context context, int textViewResourceId,
			List<ConversationSMS> objects) {
		super(context, textViewResourceId, objects);
		this.context = context;
		inflater = LayoutInflater.from(context);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
			convertView = inflater.inflate(R.layout.view_conversation_sms_item, null);
			holder = new ViewHolder();
			holder.txtName = (TextView) convertView.findViewById(R.id.txtUsernameSMS);
			holder.txtSMSValue = (TextView) convertView.findViewById(R.id.txtSMSValue);
			convertView.setTag(holder);
			final ConversationSMS converSMS = getItem(position);
			if(converSMS.isMe==1){
				holder.txtName.setText("Me");
			}else{
				holder.txtName.setText(converSMS.userName);
			}
			String smsValue = converSMS.textValue;
			holder.txtSMSValue.setText(smsValue);
		return convertView;
	}
	static class ViewHolder {
		TextView txtName;
		TextView txtSMSValue;
	}
}
